<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/fr_style.css">
		<link rel="stylesheet" href="css/card.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content-header">
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i>系统设置</a>
						</li>
						<li class="active">转账待审核列表</li>
					</ol>
				</section>
				<section class="content">
					<div class="box">
						<div class="box-header with-border">
							转账待审核列表
						</div>
						<div class="box-body">
							<div class="buyu_search_group">
								<div class="row">
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">币种</button>
											</div>
											<select type="text" class="form-control" id="coin_id">
												<option value="">请选择</option>
											</select>
										</div>
									</div>
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">地址查询</button>
											</div>
											<input type="text" class="form-control" id="search_address">
										</div>
									</div>
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">时间范围</button>
											</div>
											<!-- /btn-group -->
											<input type="text" class="form-control" id="select_time">
											<div class="input-group-addon clearBtns" onclick="clearRangeTime(this)">x</div>
										</div>
									</div>
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">发起用户</button>
											</div>
											<input type="text" class="form-control" id="from_user_id">
										</div>
									</div>
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">收款用户</button>
											</div>
											<input type="text" class="form-control" id="to_user_id">
										</div>
									</div>
									
									
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<button type="button" class="btn bg-primary margin" onclick="search()"><i class="fa fa-search" ></i>&nbsp;搜索</button>
										<button type="button" class="btn bg-primary margin" onclick="reset()"><i class="fa fa-trash" ></i>&nbsp;重置</button>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<!-- /.box-header -->
								<div class="box-body">
									<table id="example" class="display nowrap table table-bordered table-striped" style="width:100%;">
										<thead>
											<tr>
												<td>ID</td>
												<td>发起用户</td>
												<td>发起地址</td>
												<th>收款地址</th>
												<th>数量</th>
												<th>手续费</th>
												<th>时间</th>
												<th>状态</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
						</div>
					</div>

					<div class="modal fade parents in" id="checkModal">
						<div class="modal-dialog">
							<div class="modal-content">
								<div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">	        
									<span aria-hidden="true">×</span>			</button>
									<h4 class="modal-title">新增黑名单</h4> </div>
								<div class="modal-body">
									<div class="row">
										<input type="hidden" name="id"/>
										<label class="margin-bottom-none col-xs-12">审核
											<select type="text" class="form-control" name="type">
												<option value="1">通过</option>
												<option value="2">驳回</option>
											</select>
										</label>
										<label class="margin-bottom-none col-xs-12"><span class="text-red">操作密码</span>
											<input type="password" class="form-control" name="op_password">
										</label>
									</div>
								</div>
								<div class="modal-footer"><button type="button" class="btn btn-primary save" onclick="checkSave()">确定</button></div>
							</div>
						</div>
					</div>
					
					<div class="popupCon_white">
			<div class="popup_white">
				<img src="img/loading.gif" id="loading1" alt="" style="position: absolute;left: 50%;top: 50%;margin-top: -86px;margin-left: -108px;width:100px;z-index: 100" />
				<div class="popup_white_close"></div>
				<div class="popupH_white">
					<h3>机审结果</h3></div>
				<div class="popupM1_white clearfix">
					<div class="lfloat" style="padding-top: 32px;margin-right: 10px;">决策得分：</div>
					<div class="lfloat" style="line-height: 54px;font-size: 54px;font-weight: bold;margin-right: 40px;" id="machine_branch"></div>
					<div class="lfloat">
						<ul class="clearfix">
							<li>1、决策满分100分</li>
							<li>2、当用户命中相应风控点时，将扣除相应该项的分数</li>
							<li>3、权重分可前往【系统设置-机审规则配置列表】设置</li>
						</ul>
					</div>
				</div>
				<div class="popupM2_white" style="height: 320px;">
					<ul class="clearfix" id="machineInfo">
					</ul>
				</div>
				<!-- <div class="btnCon">
					<a href="javascript:void(0)" style="background: #01B543;border: 1px solid #01B543;" id="A_key_audit">一键通过</a>
					<a href="javascript:void(0)" style="background: #FF0000;border: 1px solid #FF0000;" id="refuse">驳回</a>
					<a href="javascript:void(0)" id="machineSure">机审决策</a>
				</div> -->
			</div>
		</div>
				</section>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script src="js/argument.js"></script>
		<script src="js/fun.js"></script>
		<script src="js/nav.js"></script>
		<script src="js/pop.js"></script>
		<script src="js/getList.js"></script>
		<!--<script src="js/hsjManagement_fun.js"></script>-->

		<script type="text/javascript">
			$.ajax({
				type: 'post',
				url: url + "Back_MainChainForCoin",
				contentType: "application/x-www-form-urlencoded",
				headers: {
					"auth-token": localStorage.getItem("wallet_token")
				},
				data: {
					data: JSON.stringify({
						page_num: 1
					})
				},
				dataType:'json',
				success: function(res) {
					console.log(res);
					if(res.status == 1000||res.status == 102) {
						ToLogin(res)
						return false;
					} else if(res.status != 1) {
						alert(res.error);
						return false;
					}
					$.each(res.data, function(index, item) {
						$("#coin_id").append("<option value='" + item.id + "'>" + item.name + "</option>")
					})
				}
			})
			
			$('#end_time').datepicker({
				autoclose: true,
				format: 'yyyy-mm-dd',
			})

			$(".typeNext").eq($("#type").val()).show().siblings(".typeNext").hide();
			$("#type").change(function() {
				$(".typeNext").eq($("#type").val()).show().siblings(".typeNext").hide();
			})
			var table = $('#example').DataTable({
				'ordering': false,
				'lengthChange': false,
				'searching': false,
				'info': true,
				"processing": true,
				"serverSide": true,
				'scrollX':true,
				"ajax": {
					"type": 'post',
					"url": url + "Back_UserCoinVerifyHistory",
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					"data": function(d) {
						var dataType = {
							search_address: {
								type: 'string',
								value: $("#search_address").val()
							},
							from_user_id: {
								type: 'string',
								value: $("#from_user_id").val()
							},
							to_user_id: {
								type: 'string',
								value: $("#to_user_id").val()
							},
							coin_id: {
								type: 'string',
								value: $("#coin_id").val()
							},
							start_time: {
								type: 'time',
								value: $("#select_time").val().substring(0, 16)
							},
							end_time: {
								type: 'time',
								value: $("#select_time").val().substring(19, 35)
							}
						}
						var Json = renderData(dataType);
						Json.page_num = d.start / 10 + 1;
						var data = {};
						data.data = JSON.stringify(Json);
						return data;

					},
					"dataFilter": function(data) {
						var datajson = eval('(' + data + ')');
						if(datajson.status == 1000||datajson.status == 102) {
							ToLogin(datajson)
							return false;
						} else if(datajson.status != 1) {
							alert(datajson.error);
							return false;
						}
						var json = {};
						if(datajson.data == null) {
							json.recordsTotal = 0;
							json.recordsFiltered = 0;
							json.data = [];
							return JSON.stringify(json);
						} else {
							json.recordsTotal = datajson.data.total;
							json.recordsFiltered = datajson.data.total;
							json.data = datajson.data.data_list;
							return JSON.stringify(json);
						}
					}
				},
				"columns": [{
						data: "id",
					},
					{
						data:null,render:function(data){
							return '<a href="user_dealList.html?coin_id='+data.coin_id+'&user_id='+data.from_user_id+'">'+data.from_user_id+'</a>'	
						}
					},
					{
						data: 'from_address',
					},
					{
						data: 'to_address',
					},
					{
						data: null,
						render: function(data) {
							return data.number+"&nbsp;"+data.coin_name

						}
					},
					{
						data: null,
						render: function(data) {
							return data.charge_num+"&nbsp;"+data.charge_coin_name

						}
					},
					
					{
						data: 'start_time'
					},
					{
						data: null,
						render: function(data) {
							var dataList = {
								0:{name:'进行中',color:'info'},
								1:{name:'成功',color:'success'},
								2:{name:'失败',color:'danger'},
								3:{name:'等待转账',color:'info'},
								4:{name:'等待审核',color:'info'}
							}
							return '<div class="fr_status fr_'+dataList[data.status].color+'">'+dataList[data.status].name+'</div>'
						}
					},

					{
						data: null,
						render: function(data) {
							if(data.status == 4){
								return '<button type="button" class="btn  btn-success margin" onclick="check(this)" userId="' + data.id + '">&nbsp;审核</button><button type="button" class="btn  btn-success margin" onclick="autoCheckResult('+data.id+')" userId="' + data.from_user_id + '" coinId="' + data.coin_id + '">&nbsp;机审结果</button>';
								
							}else{
								return '';
							}
							
						}
					},

				]
			})
		</script>
		<script type="text/javascript">
			function check(_this) {
				var data = $(_this).attr('userId')
				$("#checkModal [name=id]").val(data);
				$("#checkModal [name=op_password]").val('');
				$("#checkModal").modal("show")
			}

			function checkSave() {
				if($("#addModal [name=op_password]").val() == "") {
					alert("操作密码不能为空")
					return false;
				}
				$.ajax({
					type: 'post',
					url: url + "Back_VerifyCoinHistoryStatus",
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					data: {
						data: JSON.stringify({
							id: $("#checkModal [name=id]").val(),
							type: $("#checkModal [name=type]").val(),
							op_password: $("#checkModal [name=op_password]").val(),
						})
					},
					success: function(res) {
						if(res.status == 1000||res.status == 102) {
							ToLogin(res)
							return false;
						} else if(res.status != 1) {
							alert(res.error);
							return false;
						}
						$("#checkModal").modal("hide");
						alert(res.error);
						table.draw(false);
					}
				})
			}
			
//			function autoCheck(_this){
//				var user_id = $(_this).attr('userId'),coin_id = $(_this).attr('coinId');
//				$(_this).html('<i class="fa fa-load"></i>&nbsp;自动审核')
//				$.ajax({
//					type: 'post',
//					url: url + "Back_CheckCoinHistory",
//					'contentType': "application/x-www-form-urlencoded",
//					"headers": {
//						"auth-token": localStorage.getItem("wallet_token")
//					},
//					data: {
//						data: JSON.stringify({
//							user_id: user_id,
//							coin_id: coin_id
//						})
//					},
//					success: function(res) {
//						if(res.status == 1){
//							$(_this).html('通过')	.addClass('btn-success').removeClass('btn-danger').attr('disabled','disabled');
//						}else{
//							$(_this).html('异常')	.addClass('btn-danger').removeClass('btn-success').attr('disabled','disabled');
//						}
//					}
//				})
//			}
			
			function autoCheckResult(id){
				$("#machineInfo").html('');
				$(".popupCon_white").show();
				$("#loading1").show();
				var this_id = id
				$.ajax({
					type: 'post',
					url: url + "Back_GetMachineDetail",
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					data: {
						data: JSON.stringify({
							history_id: this_id
						})
					},
					success: function(res) {
						if(res.status == 1){
							$("#loading1").hide();
							$("#machine_branch").html(res.data.score);
							var str ="";
							var details = JSON.parse(res.data.details)
							if(details.length>0){
								for(var i = 0;i<details.length;i++){
									if(details[i].hit){
										str+='<li><span>'+details[i].name+'</span><img src="img/icon_unvaild.png" alt="" /><i>风险项</i><em>'+details[i].score+'</em></li>'//'+resJSON.Hit_points[i]
									}else{
										str+='<li><span>'+details[i].name+'</span><img src="img/icon_through.png" alt="" /><i class="success">通过</i></li>'
									}
								}
								$("#machineInfo").append(str)
							}
						}else if(res.status == 1000||res.status == 102){
							ToLogin(res)
						}else{
							alert(res.error)
						}
					}
				})
			}
			
			$('.popup_white_close').click(function() {
				$(".popupCon_white").css('display', 'none');
			})
		</script>
	</body>

</html>